package c.m.d.b.assembler;

import c.m.d.b.beans.PropertyType;
import c.m.d.b.view.PropertyTypeView;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public final class PropertyTypeAssembler
{
    private PropertyTypeAssembler()
    {
    }

    public static PropertyTypeView convert(PropertyType type)
    {
        PropertyTypeView view = new PropertyTypeView();
        view.setDataType(type.getDataType());
        view.setPropertyTypeName(type.getPropertyTypeName());
        view.setMandatory(type.isMandatory());
        return view;
    }

    public static Map<String, PropertyTypeView> convert(Collection<PropertyType> types)
    {
        Map<String, PropertyTypeView> map = new HashMap<String, PropertyTypeView>();
        for (PropertyType type : types)
        {
            PropertyTypeView view = convert(type);
            map.put(view.getPropertyTypeName(), view);
        }
        return map;
    }
}
